Skip to content

Give declared users view or edit access to Kibana (S-024-6, S-024-7) - #611

Merged
shipmill-romamo[bot] merged 1 commit into
mainfrom
feat/572-kibana-access
Nov 24, 2026
Merged

shipmill-romamo[bot] merged 1 commit into
mainfrom
feat/572-kibana-access

Conversation

@shipmill-romamo

Copy link
Copy Markdown
Contributor

Plan

  • Serves: G-1, G-3
  • Files: engine/ansible/roles/cloudfall_kibana/tasks/roles.yml (new), engine/ansible/roles/cloudfall_kibana/tasks/main.yml (one include), engine/ansible/roles/cloudfall_elasticsearch/tasks/users.yml, engine/ansible/roles/cloudfall_elasticsearch/defaults/main.yml, engine/ansible/roles/cloudfall_elasticsearch/meta/argument_specs.yml, engine/ansible/playbooks/services.yml, engine/tests/test_s024_kibana_access.py (new), changelog.d/572-kibana-access.md
  • Order: (1) the Kibana role writes cloudfall-kibana-view (base read) and cloudfall-kibana-edit (base all) on every space, with no Elasticsearch privilege, through Kibana's role API, reading each first so an unchanged role is not put again; (2) services.yml hands the Elasticsearch role the access of each user the cluster's Kibana service names; (3) the S-012 user converge gives a named user the Kibana role of its access next to its own role, takes it from a user no longer named, and leaves an unnamed user's roles exactly as they are; a change of roles alone sends no password hash, so a password the person changed in Kibana stays (S-024, People and what they may do); (4) tests, changelog fragment
  • Proof: S-024-6, S-024-7: engine/tests/test_s024_kibana_access.py runs the user tasks and the role tasks for real with ansible-playbook against stand-ins of Elasticsearch's security API and Kibana's role API (the roles each request puts, a second converge putting nothing, taking access away, the users' own roles holding no application privilege, no_log on every task that sees a password); what only a live Kibana proves (logging in, a data view and a dashboard, a refused save) is listed as unverified
  • Tests changed: none

Summary

Builds S-024-6 and S-024-7 of spec 024: who may work in Kibana.

  • The two roles (cloudfall_kibana/tasks/roles.yml, included from main.yml once Kibana reports itself available, never in check mode): cloudfall-kibana-view is Kibana's base privilege read and cloudfall-kibana-edit its base all, both on every space (spaces: ["*"]) with empty cluster, indices and run_as, so neither reaches an index or manages users and roles. They are written with PUT /api/security/role/<name> (with kbn-xsrf), after a GET of each: a role already holding exactly that is not put again, one changed by hand is. They carry metadata.cloudfall_managed_by: <kibana service id>, so the S-012 user converge, which only deletes roles marked with the Elasticsearch service's id, never touches them. As the maintainer accepted for Kibana service: Kibana converged on a node, with its token and keys (S-024-3, S-024-4, S-024-5) #569, the role talks to Kibana as the cloudfall account over loopback
  • Who holds them: services.yml hands the Elasticsearch role cloudfall_elasticsearch_kibana_access, the access of each user named in kibana.users of the cluster's Kibana service, read from every server's cloudfall_services (the Kibana service lands on its own server only, which need not be the home that converges users). users.yml puts a named user with [<own role>, cloudfall-kibana-<access>] and an unnamed one with [<own role>], as before. The user's own role is untouched: a dashboard shows that person only its indexPatterns
  • No churn: a user Kibana does not name, on a cluster S-012 already converged, gets no request at all. Removing a line puts that user once, with its own role alone; its role and password stay
  • Passwords: the user PUT now carries password_hash only when the user is new or its stored password's digest changed. Giving or taking Kibana access (or re-enabling a user) no longer resends the hash, so a password the person changed in Kibana stays, as the spec's People section says. A rotated password is still sent

A name in kibana.users that the Elasticsearch service does not declare is already refused at validation (service_kibana_user_unknown, #567).

Test notes

  • New: engine/tests/test_s024_kibana_access.py (12 tests). The user tasks of cloudfall_elasticsearch and the role tasks of cloudfall_kibana run for real with ansible-playbook -vvv --diff on localhost against one stand-in answering Elasticsearch's security API and Kibana's role API (it refuses a Kibana PUT without kbn-xsrf, and keeps a Kibana role as Elasticsearch does, with privileges of kibana-.kibana). They prove the two role bodies, analyst and support holding their own role plus the Kibana role of their access, no index of either reaching billing-1, a second converge with changed=0 and no write, an unnamed user holding its own role alone with no application privilege, access given to a converged cluster touching only the named users and sending no hash, removing analyst sending one user PUT with no hash and leaving its role and password, a role changed by hand being put again, a rotated password still sent, no password or hash in the output, no_log on every task seeing the password, and the services.yml expression finding the access when Kibana runs on a node other than the home
  • specs.py coverage --spec 024 lists tests for S-024-6 and S-024-7
  • Ran locally: ruff check ., mypy, ansible-lint engine/ansible (with ANSIBLE_CONFIG=engine/ansible/ansible.cfg, as CI), and pytest on the new file plus test_s012_elasticsearch_users.py, test_s024_kibana_role.py, test_s012_elasticsearch_role.py, test_s023_rabbitmq_role.py, test_s024_kibana_render.py (91 passed). The full suite is left to CI

Unverified live (needs a Debian 13 host with Elastic's packages):

  • analyst logging in, creating a data view on crm-* and a dashboard, and seeing no document of billing-1; support opening it and being refused a save
  • an unnamed user, and analyst after removal, getting Kibana's no-access page while analyst's search of crm-1 still works
  • the exact shape Kibana 9's GET /api/security/role/<name> answers (the comparison defaults missing keys, and reads remote_indices too), and Kibana accepting the cloudfall file-realm superuser for its role API
  • Elasticsearch keeping a user's password on a PUT without password_hash

Fixes #572

🤖 Generated with Claude Code

@shipmill-romamo shipmill-romamo Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: MERGE at 42bea4e. No fix commits.

Checks: ruff, mypy, ansible-lint (CI config) clean; touched tests 67 passed (new S-024 access tests, S-012 users and role tests, S-024 Kibana role tests). specs.py coverage --spec 024 lists tests for S-024-6 and S-024-7; its exit 1 is for criteria other issues build.

Verified: the password hash is sent only for a new user or a changed stored hash, so granting or taking Kibana access never resets a password, and nothing in S-012 relied on the resend. Users not named in kibana.users get no request; removing a line drops only the Kibana role; a second converge changes nothing. The S-012 cleanup deletes only roles tagged with the Elasticsearch service id, so the Kibana roles survive. services.yml picks the cluster by kibana.elasticsearch. Every password task is no_log; the two roles hold no cluster, index, or run_as privilege.

Unverified live: a real login, a refused save, Kibana 9's role response (stand-in API only).

Notes (not blocking):

  • F-1 (nit): cloudfall_inspect/tasks/elasticsearch_users.yml:97-102: audit lists the two Kibana roles as not made by Cloudfall; status stays compliant. Fits S-024-13 (#582)
  • F-2 (nit): removing the Kibana service leaves both roles on the cluster

History: H-1, H-7, H-9 consistent; the rest unrelated; #610 and #597 also edit services.yml.

The Kibana role keeps cloudfall-kibana-view (base read) and
cloudfall-kibana-edit (base all) on every space, with no Elasticsearch
privilege, through Kibana's role API, reading each first so a second
converge puts nothing. services.yml hands the Elasticsearch role the
access of each user its cluster's Kibana names, and the S-012 user
converge gives that user the matching Kibana role next to its own role,
taking it away when the line is removed. Users Kibana does not name keep
exactly their own role. A change of roles alone sends no password hash,
so a password the person changed in Kibana stays.

Fixes #572

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shipmill-romamo
shipmill-romamo Bot force-pushed the feat/572-kibana-access branch from 42bea4e to 4582661 Compare November 24, 2026 10:31

@shipmill-romamo shipmill-romamo Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: MERGE at 4582661, the earlier MERGE review of 42bea4e rebased onto main after #610 (Kibana published through a Domain) landed.

  • git range-diff reads the PR's one commit as identical (42bea4e = 4582661); the rebase was clean
  • #610 and this PR both edit engine/ansible/playbooks/services.yml and cloudfall_kibana/tasks/main.yml, in separate places. The new roles.yml still calls Kibana on cloudfall_kibana_url, the loopback listener #610 keeps for the role's own calls, so publishing through a Domain doesn't change where the role API is reached
  • Ran on the rebased tree: pytest on test_s024_kibana_access.py, test_s024_8_kibana_domain.py, test_s024_kibana_role.py, test_s012_elasticsearch_users.py (50 passed); changelog_guard.py check clean (one fragment)
  • CI on 4582661: checks, checks (Python 3.15) and converge green

Unverified live, as the PR body lists: logins and refused saves in a real Kibana, the shape of Kibana 9's role API answer, and Elasticsearch keeping a password on a PUT without password_hash.

@shipmill-romamo
shipmill-romamo Bot merged commit 8373bb4 into main Nov 24, 2026
3 checks passed
@shipmill-romamo
shipmill-romamo Bot deleted the feat/572-kibana-access branch November 24, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kibana service: view and edit access for declared users (S-024-6, S-024-7)

0 participants